<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/13
 * Time: 15:42
 */

namespace common\consts;

use Yii;
class Consts
{
    const DEFAULT_PAGE_SIZE = 20;
    const SEPARATOR = ',';
    const DECIMAL_SEPARATOR = '.';
    const BACKEND_FILE_UPLOAD_PATH = '@backend/runtime/uploads/';
    const MAX_STRING_LENGTH = 2048;

    const ID_UNKNOWN = -1;

//    每次反写的百分比
    const RATE_RANGE = 0.01;

    const TASK_MAX_RETRY_TIMES = 5;

    const GENDER_MALE = 1;
    const GENDER_FEMALE = 2;
    const GENDER_NOT_DEFINED  = 0;

    const ACCESS_TOKEN_STATUS_ACTIVE = 1;
    const ACCESS_TOKEN_STATUS_INACTIVE = 2;

    const QYWX_USER_STATUS_ACTIVATED = 1;
    const QYWX_USER_STATUS_DISABLED = 2;
    const QYWX_USER_STATUS_UN_ACTIVATED = 4;

//    文件状态,同步中=-1,新建待处理=0,处理中=1,处理完毕=2
    const FILE_STATUS_SYNCHRONIZING = -1;
    const FILE_STATUS_NEW = 0;
    const FILE_STATUS_IN_PROCESS = 1;
    const FILE_STATUS_FINISHED = 2;

//        同步状态,同步中=-1,待同步=0,已同步=1,同步失败=2
    const SYNC_STATUS_SYNCHRONIZING = -1;
    const SYNC_STATUS_NEW = 0;
    const SYNC_STATUS_FINISHED = 1;
    const SYNC_STATUS_FAILED = 2;
    public static function SYNC_STATUS_MAP(){
        return [
            self::SYNC_STATUS_SYNCHRONIZING => Yii::t('app', 'Synchronizing'),
            self::SYNC_STATUS_NEW => Yii::t('app', 'New Created'),
            self::SYNC_STATUS_FINISHED => Yii::t('app', 'Synchronized'),
            self::SYNC_STATUS_FAILED => Yii::t('app', 'Synchronize Failed'),
        ];
    }

//    文件处理结果,未处理=0,成功=1,失败=2
    const FILE_RESULT_CODE_INIT = 0;
    const FILE_RESULT_CODE_SUCCESS = 1;
    const FILE_RESULT_CODE_FAIL = 2;

    const YES = 1;
    const NO = 0;
    const OK = 'ok';
    const ERROR = 'error';

    const QYWX_USER_IS_LEADER = 1;
    const QYWX_USER_IS_NOT_LEADER = 0;

//    血型 未知=0,A=10,B=20,AB=30,O=40,其他=90
    const KD_BLOOD_TYPE_UN_KNOWN = 0;
    const KD_BLOOD_TYPE_A = 10;
    const KD_BLOOD_TYPE_B = 20;
    const KD_BLOOD_TYPE_AB = 30;
    const KD_BLOOD_TYPE_O = 40;
    const KD_BLOOD_TYPE_OTHER = 90;

// 组织类型 无=-1,行政组织=0,财务组织=1,销售组织=2,采购组织=3,库存组织=4,成本中心=5,利润中心=6,合并范围=8,管理单元=10,HR组织=16,发运组织=24,质检组织=32
    const KD_ORG_TYPE_NULL = -1;
    const KD_ORG_TYPE_ADMIN = 0;
    const KD_ORG_TYPE_FINANCE = 1;
    const KD_ORG_TYPE_SALES = 2;
    const KD_ORG_TYPE_PURCHASE = 3;
    const KD_ORG_TYPE_INVENTORY = 4;
    const KD_ORG_TYPE_COST_CENTER = 5;
    const KD_ORG_TYPE_PROFIT_CENTER = 6;
    const KD_ORG_TYPE_MERGE_RANGE = 8;
    const KD_ORG_TYPE_CONTROL_UNIT = 10;
    const KD_ORG_TYPE_HR = 16;
    const KD_ORG_TYPE_FORWARDING  = 24;
    const KD_ORG_TYPE_QUALITY_TEST = 32;

    const KD_LOCALE_ENGLISH = 'L1';
    const KD_LOCALE_SIMPLIFIED_CHINESE = 'L2';
    const KD_LOCALE_TRADITIONAL_CHINESE = 'L3';

    const DEFAULT_PROMPT_PLS_SELECT = '===请选择===';

    const TASK_PRIORITY_1 = 1;
    const TASK_PRIORITY_2 = 2;
    const TASK_PRIORITY_3 = 3;
    const TASK_PRIORITY_4 = 4;
    const TASK_PRIORITY_5 = 5;
    const TASK_PRIORITY_6 = 6;
    const TASK_PRIORITY_7 = 7;

    const TASK_STATUS_OPEN       = 0;
    const TASK_STATUS_RUNNING    = 1;
    const TASK_STATUS_FINISHED   = 2;
    const TASK_STATUS_TERMINATED = 3;
    const TASK_STATUS_ERROR      = 4;
    public static function TASK_STATUS_MAP(){
        return [
            self::TASK_STATUS_OPEN => Yii::t('app', 'Open'),
            self::TASK_STATUS_RUNNING => Yii::t('app', 'Running'),
            self::TASK_STATUS_FINISHED => Yii::t('app', 'Finished'),
            self::TASK_STATUS_TERMINATED => Yii::t('app', 'Terminated'),
            self::TASK_STATUS_ERROR => Yii::t('app', 'Error'),
        ];
    }

//    任务类型
    const TASK_TYPE_EMPLOYEE = 'task_type_employee';
    const TASK_TYPE_COMPANY = 'task_type_company';
    const TASK_TYPE_DEPARTMENT = 'task_type_department';
    const TASK_TYPE_EXCEL_TO_EMPLOYEE = 'task_type_excel_to_employee';
    const TASK_TYPE_DEPARTMENT_FROM_QYWX = 'task_type_department_from_qywx';
    const TASK_TYPE_KD_TO_QYWX = 'task_type_kd_to_qywx';
    const TASK_TYPE_CASCADE_DELETE_QYWX_DEPARTMENT = 'task_type_delete_qywx_department';
    const TASK_TYPE_EMPLOYEE_DEPARTMENT = 'task_type_employee_department';
    const TASK_TYPE_EMPLOYEE_TO_QYWX = 'task_type_employee_to_qywx';
    const TASK_TYPE_POSITION = 'task_type_position';
    const TASK_TYPE_EMPLOYEE_POSITION = 'task_type_employee_position';
    const TASK_TYPE_DEPARTMENT_FROM_HR = 'task_type_department_from_hr';
    const TASK_TYPE_DEPARTMENT_TO_QYWX = 'task_type_department_to_qywx';
    const TASK_TYPE_ORG_TO_TREE = 'task_type_org_tree';
    const TASK_TYPE_EMPLOYEE_PHOTO = 'task_type_employee_photo';
    const TASK_TYPE_MDM_ORG = 'task_type_mdm_org';
    const TASK_TYPE_MDM_TASK = 'task_type_mdm_task';
    const TASK_TYPE_MDM_DEPT = 'task_type_mdm_dept';
    const TASK_TYPE_MDM_POSITION = 'task_type_mdm_position';
    const TASK_TYPE_MDM_EMPLOYEE = 'task_type_mdm_employee';
    public static function TASK_TYPE_MAP(){
        return [
            self::TASK_TYPE_EMPLOYEE => Yii::t('app', 'Employee'),
            self::TASK_TYPE_COMPANY => Yii::t('app', 'Company'),
            self::TASK_TYPE_DEPARTMENT => Yii::t('app', 'Department'),
            self::TASK_TYPE_EXCEL_TO_EMPLOYEE => Yii::t('app', 'Import Employee From Excel'),
            self::TASK_TYPE_DEPARTMENT_FROM_QYWX => Yii::t('app', 'Sync Department From Qywx'),
            self::TASK_TYPE_KD_TO_QYWX => Yii::t('app', 'Kingdee To Qywx'),
            self::TASK_TYPE_CASCADE_DELETE_QYWX_DEPARTMENT => Yii::t('app', 'Cascade Delete Qywx Department'),
            self::TASK_TYPE_EMPLOYEE_DEPARTMENT => Yii::t('app', 'Employee Department Relation'),
            self::TASK_TYPE_EMPLOYEE_TO_QYWX => Yii::t('app', 'Sync Employee To Qywx'),
            self::TASK_TYPE_POSITION => Yii::t('app', 'Sync Position'),
            self::TASK_TYPE_EMPLOYEE_POSITION => Yii::t('app', 'Sync Employee Position Relation'),
            self::TASK_TYPE_DEPARTMENT_FROM_HR => Yii::t('app', 'Sync Department From HR'),
            self::TASK_TYPE_DEPARTMENT_TO_QYWX => Yii::t('app', 'Sync Department To Qywx'),
            self::TASK_TYPE_ORG_TO_TREE => Yii::t('app', 'Sync Org Tree'),
            self::TASK_TYPE_EMPLOYEE_PHOTO => Yii::t('app', 'Sync Employee Photo'),
            self::TASK_TYPE_MDM_ORG => Yii::t('app', 'Sync Mdm Org'),
            self::TASK_TYPE_MDM_TASK => Yii::t('app', 'Execute Mdm Task'),
            self::TASK_TYPE_MDM_DEPT => Yii::t('app', 'Sync Mdm Dept'),
            self::TASK_TYPE_MDM_POSITION => Yii::t('app', 'Sync Mdm Position'),
            self::TASK_TYPE_MDM_EMPLOYEE => Yii::t('app', 'Sync Mdm Employee'),
        ];
    }

//在职=1,不在职=0,离职=2,离退休=3,返聘=4
    const KD_IN_SERVICE_IN = 1;
    const KD_IN_SERVICE_NOT_IN = 0;
    const KD_IN_SERVICE_LEAVED = 2;
    const KD_IN_SERVICE_RETIRED = 3;
    const KD_IN_SERVICE_RETIRED_BACK = 4;
    public static function KD_IN_SERVICE_MAP(){
        return [
            self::KD_IN_SERVICE_IN => Yii::t('app', 'In Service'),
            self::KD_IN_SERVICE_NOT_IN => Yii::t('app', 'Not In Service'),
            self::KD_IN_SERVICE_LEAVED => Yii::t('app', 'Leaved'),
            self::KD_IN_SERVICE_RETIRED => Yii::t('app', 'Retired'),
            self::KD_IN_SERVICE_RETIRED_BACK => Yii::t('app', 'Retired Back'),
        ];
    }

//雇佣=0,外部人员=1,其他=2
    const KD_WORK_RELATION_HIRE = 0;
    const KD_WORK_RELATION_EXTERNAL_PERSON = 1;
    const KD_WORK_RELATION_OTHER = 2;
    public static function KD_WORK_RELATION_MAP(){
        return [
            self::KD_WORK_RELATION_HIRE => Yii::t('app', 'Hire'),
            self::KD_WORK_RELATION_EXTERNAL_PERSON => Yii::t('app', 'External Person'),
            self::KD_WORK_RELATION_OTHER => Yii::t('app', 'Other'),
        ];
    }

//启用=1,禁用=2
    const KD_USER_STATE_ACTIVE = 1;
    const KD_USER_STATE_FORBID = 2;
    public static function KD_USER_STATE_MAP(){
        return [
            self::KD_USER_STATE_ACTIVE => Yii::t('app', 'Active'),
            self::KD_USER_STATE_FORBID => Yii::t('app', 'Forbid'),
        ];
    }

    const ASC = 'asc';
    const DESC = 'desc';
    public static function SORT_ORDER_MAP(){
        return [
            self::ASC => SORT_ASC,
            self::DESC => SORT_DESC,
        ];
    }

//    0=>初始,1=>成功,-1=>失败,2=>运行中
    const MDM_TASK_FLAG_INIT = 0;
    const MDM_TASK_FLAG_SUCCESS = 1;
    const MDM_TASK_FLAG_FAIL = -1;
    const MDM_TASK_FLAG_RUNNING = 2;
    public static function MDM_TASK_FLAG_MAP(){
        return [
            self::MDM_TASK_FLAG_INIT => Yii::t('app', 'Initial'),
            self::MDM_TASK_FLAG_SUCCESS => Yii::t('app', 'Success'),
            self::MDM_TASK_FLAG_FAIL => Yii::t('app', 'Fail'),
            self::MDM_TASK_FLAG_RUNNING => Yii::t('app', 'Running'),
        ];
    }
}